<link rel="stylesheet" type="text/css" href="/assets/css/ward.css" />
<div class="red" id="red"><img src="/assets/img/gift02.png" srcs="0" class="imgbox"></div>


<eq name="award" value="noaward">

	<script type="text/javascript">
	$(function(){
		$("#red").click(function(){
			$(".red").addClass("shake");
			alert('此奖品已被人领取！');
			$(".red").removeClass("shake");
			$(".poplayerma").hide();
			$(".red").hide();
		});
	});
	</script>

<else/>

	<input type="hidden" name="urladdres" value="{$getURL}" />
	<input type="hidden" name="getshaddres" value="{$reginfo|count}" />
	<switch name="award.awardkind">
		<case value="2">
			<!--实物奖品-->
			<div class="poplayerma" id="type2" style="display:none;">
			    <div class="float-gift">
			        <div class="getward">
			            <div class="w_left">恭喜您，获得“{$award['awardname']}”<b>注：请填写以下相关信息，以保证奖品及时送达您手中。</b></div>
			            <div class="w_right"><img class="jpimg" src="{$award['awardimg']}" height="60"/><span>奖品缩略图</span></div>
			        </div>
			        <if condition="$reginfo|count neq 0">
			        <div class="getshaddres">
			            <div class="input-box clearfix"><label for="username">收货地址:</label></div>
			            <div class="input-box clearfix saddress">
			                <input type="radio" name="saddress" value="1" checked> {$reginfo['username']} {$reginfo['address']}
			            </div>
			        </div>
			        <elseif condition="$reginfo|count eq 0" />
			            <div class="otherinfo">
			                <div class="input-box clearfix">
			                    <label for="username">姓 名:</label>
			                    <input type="text" name="username" id="username">
			                </div>
			                <div class="input-box clearfix">
			                    <label for="usertel">手机号:</label>
			                    <input name="usertel" type="tel" id="usertel">
			                </div>
			                <div class="input-box clearfix">
			                    <label for="jishi"></label>
			                    <input name="jishi" class="shiwujishi" type="button" id="jishi" value="获取验证码">
			                </div>
			                <div class="input-box clearfix">
			                    <label for="userpass">验证码:</label>
			                    <input type="text" name="userpass" id="userpass">
			                </div>
			                <div class="input-box clearfix">
			                    <label for="address">地 址:</label>
			                    <input type="text" name="address" id="address">
			                </div>
			            </div>
			        </if>
			        <p><if condition="($rootid eq 383) or ($rootid eq 384)">注：抽到的优惠券不找零不提现<else/>请提交信息，我们会尽快将奖品送出</if></p>
			        <if condition="$rootid eq 275"><p style="font-size: 16px;">兑奖热线：<a href="tel:4006006955" style="display: inline; color: #ff5c5d">4006006955</a></p></if>
			        <div class="btn-box clearfix">
			            <a class="sure-btn">确认领取</a>
			            <a class="del-btn">取消</a>
			        </div>
			    </div>
			</div>
		</case>
		<case value="3">
			<!--红包-->
			<div class="poplayerma" id="type3" style="margin-top: 20%; display:none;">
			    <div class="float-gift" style="padding:0px; background-color: #fff2c5;">
			        <div class="float-bg"><img src="/assets/img/float-bg.png"></div>
			        <div class="content-box" style="width: 100%; padding-top: 40px;">
			            <h4 id="h4html" class="hbmesg">-</h4>
			            <div class="gift-box">
			                <div class="pic-gift"><img src="/assets/img/redbag.png"></div>
			            </div>
			            <span>请返回微信最近联系人列表栏<br/>置顶公众号或服务通知中领取红包</span>
			        </div>
			    </div>
			</div>
		</case>
		<case value="1">
			<!--华人钻-->
			<div class="poplayerma" id="type1" style="margin-top: 20%; display:none;">
				<div class="float-gift" style="padding:0px; background-color: #fff2c5;">
				    <div class="float-bg"><img src="/assets/img/float-bg.png"></div>
				    <div class="content-box" style="width: 100%; padding-top: 40px;">
				        <h4 id="h4html" class="dillmsg">-</h4>
				        <div class="gift-box">
				            <div class="pic-gift"><img src="/assets/img/diamond.png"></div>
				        </div>
				        <!--<a href="http://hrshop.hrtv.cn/index.php?controller=ucenter&action=index" class="alink-btn"><img src="/assets/img/btn.png"><i>点击查看</i></a>-->
				    </div>
				</div>
			</div>
		</case>
		<case value="5">
			<!--话费充值-->
			<div class="poplayerma" id="type5" style="display:none;">
			    <div class="float-gift">
			        <div class="getward">
			            <div class="w_left">恭喜您，获得 {$award['awardteltopup']}元话费 奖品<b>注：请填写你需要充值话费的手机号码，小额充值运营商可能没有短信提醒，请自助查询。</b></div>
			            <div class="w_right"><img class="jpimg" src="/assets/img/xjzccard.jpg" height="60"/><span>奖品缩略图</span></div>
			        </div>
			        <div class="otherinfo">
			             <div class="input-box clearfix">
			                    <label for="usertel">手机号:</label>
			                    <input name="usertel" type="tel" id="usertel">
			             </div>
			             <div class="input-box clearfix">
			                    <label for="jishi"></label>
			                    <input name="jishi" class="haufeijishi" type="button" id="jishi" value="获取验证码">
			             </div>
			             <div class="input-box clearfix">
			                    <label for="userpass">验证码:</label>
			                    <input type="text" name="userpass" id="userpass">
			             </div>
			        </div>
			        <div class="btn-box clearfix">
			            <a class="huafei-btn">确认领取</a>
			            <a class="del-btn">取消</a>
			        </div>
			    </div>
			</div>
		</case>
		<case value="4">
			<!--流量充值-->
			<div class="poplayerma" id="type4" style="display:none;">
			    <div class="float-gift">
			        <div class="getward">
			            <div class="w_left">恭喜您，获得 手机流量包 奖品<b>注：请填写你需要充值流量的手机号码</b></div>
			            <div class="w_right"><img class="jpimg" src="/assets/img/mllbao.jpg" height="60"/><span>奖品缩略图</span></div>
			        </div>
			        <div class="otherinfo">
			             <div class="input-box clearfix">
			                    <label for="usertel">手机号:</label>
			                    <input name="usertel" type="tel" id="usertel">
			             </div>
			             <div class="input-box clearfix">
			                    <label for="jishi"></label>
			                    <input name="jishi" class="haufeijishi" type="button" id="jishi" value="获取验证码">
			             </div>
			             <div class="input-box clearfix">
			                    <label for="userpass">验证码:</label>
			                    <input type="text" name="userpass" id="userpass">
			             </div>
			        </div>
			        <div class="btn-box clearfix">
			            <a class="liuliang-btn">确认领取</a>
			            <a class="del-btn">取消</a>
			        </div>
			    </div>
			</div>
		</case>
	
	</switch>
	
	<script type="text/javascript">
	$(function(){
		var randcode = '{$randcode}';
	
		$("#red").click(function(){
			var obj  = $(".red");
			obj.addClass("shake");
	
			var url  = "/handle";
			var data = {random:Math.random()};
			$.ajax({
				url:url,
				data:data,
				type:"POST",
				dataType:"JSON",
				success:function (datas){
					$(this).find(".imgbox").attr("srcs",0);
					$(this).find(".imgbox").attr("src","/assets/img/gift02.png");
					switch (datas.type){
						case 0:
							alert(datas.message);
							break;
						case 3:
							$("#type3").show();
							$(".hbmesg").html(datas.message);
							break;
						case 33:
							alert(datas.message);
							break;
						case 2:
							$("#type2").show();
							break;
						case 1:
							alert("很遗憾，未中奖！");
							//$("#type1").show();
							//$(".dillmsg").html("恭喜您，获得 <em style='font-style:normal;color:#ec0f0f;'>"+datas.diamond+"</em> 个华人钻");
							break;
						case 5:
							$("#type5").show();
							break;
						case 4:
							$("#type4").show();
							break;		
					}
					
					obj.removeClass("shake");
					//$(".poplayerma").hide();
					obj.hide();
				},
				error: function(e) {
					//alert(11);
				}
			});
	
		});
	
		/* 话费充值奖品发送手机验证码 */
		$(".haufeijishi").click(function(){
			var mobile 	= $("input[name='usertel']").val();
			if(telcheck(mobile)){
				sendverifynote(mobile);
			}
		})
		/* 提交流量充值 */
		$("a.liuliang-btn").click(function(){
			var t = $(this);
			var userpass 	= $("input[name='userpass']").val();
			var mobile 		= $("input[name='usertel']").val();
			if(telcheck(mobile)){
				t.removeClass('liuliang-btn');
				var vget_url = "/getverifynote";
				var vdata = {"userpass":userpass,random:Math.random()};
				$.ajax({
					url:vget_url,
					data:vdata,
					type:"POST",
					dataType:"html",
					success:function (data){
						//判断验证码是否正确
						if(data == 1){
							//手机验证通过
							flow_infos(mobile);
						}else{
							alert("验证码不正确，请重新获取！");
							t.addClass('liuliang-btn');
							return false;
						}
					}
				});
			}
		})
		/* 流量充值业务逻辑处理 */
		function flow_infos(mobile){
			var send_url = "/flowbusiness";
			var senddata = {"usertel":mobile,random:Math.random()};
			$.ajax({
				url:send_url,
				data:senddata,
				type:"POST",
				dataType:"JSON",
				success:function (data){
					// 处理结果
					alert(data.message);
					$(".otherinfo input").each(function(index,element){
						$(this).val(null);
					})
					$("#type4").hide();
					var obj = $(".red");
					obj.addClass("shake");
					obj.hide();
				}
			});
		}
		/* 提交话费充值 */
		$("a.huafei-btn").click(function(){
			var t = $(this);
			var userpass 	= $("input[name='userpass']").val();
			var mobile 		= $("input[name='usertel']").val();
			if(telcheck(mobile)){
				t.removeClass('huafei-btn');
				var vget_url = "/getverifynote";
				var vdata = {"userpass":userpass,random:Math.random()};
				$.ajax({
					url:vget_url,
					data:vdata,
					type:"POST",
					dataType:"html",
					success:function (data){
						//判断验证码是否正确
						if(data == 1){
							//手机验证通过
							rechargeableinfos(mobile);
						}else{
							alert("验证码不正确，请重新获取！");
							t.addClass('huafei-btn');
							return false;
						}
					}
				});
			}
		})
		/* 话费充值业务逻辑处理 */
		function rechargeableinfos(mobile){
			var send_url = "/topupbusiness";
			var senddata = {"usertel":mobile,random:Math.random()};
			$.ajax({
				url:send_url,
				data:senddata,
				type:"POST",
				dataType:"JSON",
				success:function (data){
					// 处理结果
					alert(data.message);
					$(".otherinfo input").each(function(index,element){
						$(this).val(null);
					})
					$("#type5").hide();
					var obj = $(".red");
					obj.addClass("shake");
					obj.hide();
				}
			});
		}
	
		/* 实物奖品发送手机验证码 */
		$(".shiwujishi").click(function(){
			var mobile 	= $("input[name='usertel']").val();
			if(telcheck(mobile)){
				//先判断是否有注册信息
				var savetel_url = "/isreginfo";
				var teldata = {"usertel":mobile,random:Math.random()};
				$.ajax({
					url:savetel_url,
					data:teldata,
					type:"POST",
					dataType:"html",
					success:function (data){
						if(data==0){
							sendverifynote(mobile);
						}
					}
				});
			}
		})
	
		/* 保存注册信息 */
		$("a.sure-btn").click(function(){
			var t = $(this);
			var userpass 	= $("input[name='userpass']").val();
			var mobile 		= $("input[name='usertel']").val();
			var username 	= $("input[name='username']").val();
			var address 	= $("input[name='address']").val();
			var saddress 	= $("input[name='saddress']").val();
			if(saddress==1){
				//$(this).removeClass('sure-btn');
				var userinfoid = $("input[name='userinfoid']").val();
				addreginfos(randcode,"{$reginfo['tel']}","{$reginfo['username']}","{$reginfo['address']}");
			}else{
				if($.trim(username)==''){
					alert('请填写姓名！');
					return false;
				}
				if($.trim(address)==''){
					alert('请填写收货地址！');
					return false;
				}
				t.removeClass('sure-btn');
				var vget_url = "/getverifynote";
				var vdata = {"userpass":userpass,random:Math.random()};
				$.ajax({
					url:vget_url,
					data:vdata,
					type:"POST",
					dataType:"html",
					success:function (data){
						/*判断验证码是否正确*/
						if(data==1){
							/*手机验证通过*/
							addreginfos(randcode,mobile,username,address);
						}else{
							alert("验证码不正确，请重新获取！");
							t.addClass('sure-btn');
							return false;
						}
	
					}
				});
			}
		})

		//保存信息
		function addreginfos(randcode,mobile,username,address){
			var send_url = "/addresreg";
			var senddata = {"randcode":randcode,"usertel":mobile,"username":username,"address":address,random:Math.random()};
			$.ajax({
				url:send_url,
				data:senddata,
				type:"POST",
				dataType:"JSON",
				success:function (datas){
	
					alert(datas.message);
					$(".otherinfo input").each(function(index,element){
						$(this).val(null);
					})
					$("#type2").hide();
					var obj = $(".red");
					obj.addClass("shake");
					obj.hide();
	
				}
			});
		}
	
	
		/* ====================================公用函数=================================== */
		/* 发送验证码 */
		function sendverifynote(mobile){
			var jis = $("input[name='jishi']");
			jis.attr('disabled','disabled');
			var send_url = "/verifynote";
			var senddata = {"usertel":mobile,random:Math.random()};
			$.ajax({
				url:send_url,
				data:senddata,
				type:"POST",
				dataType:"html",
				success:function (data){
				}
			});
			$("input[name='userpass']").focus();
			settime();
		}
		/* 手机号码检测 */
		function telcheck(mobile){
			var reg 	= /^0?1[3|4|5|8|7][0-9]\d{8}$/;
			if (!reg.test(mobile)) {
				alert("请输入正确的手机号码！");
				$("input[name='usertel']").val(null);
				$("input[name='usertel']").focus();
				return false;
			}else{
				return true;
			}
		}	
		/* 倒计时 */
		var countdown = 30;
		function settime() {
			if (countdown == 0) {
				$("#jishi").val("获取验证码");
				$("#jishi").removeAttr('disabled');
				countdown = 30;
				return;
			} else {
				$("#jishi").val("重新发送("+countdown+")");
				countdown--;
			}
			setTimeout(function() {
				settime()
			},1000)
		}
	
		$(".del-btn").click(function(){
			$(".poplayerma").hide();
			$(".red").hide();
		});
		$(".poplayerma").click(function(event){
			$(".poplayerma").hide();
			$(".red").hide();
			event.stopPropagation();
		});
		$(".float-gift").click(function(event){
			event.stopPropagation();
		})
	
	
	});
	</script>
</eq>